

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.AirlineReservationServiceProxy;
import bean.Flight;
import bean.Journey;
import constants.AirlineReservationServiceConstants;

/**
 * Servlet implementation class listAllFlightsServlet
 */
public class listAllFlightsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		
		
		Flight[] allFlights = proxy.viewFlights();
		List<Flight> lstFlights = new ArrayList<Flight>();
		
		
		if(allFlights!= null)
			lstFlights = Arrays.asList(allFlights);
			
		req.setAttribute("lstFlights", lstFlights);
		//req.setAttribute("from", req.getParameter("from"));
		req.getRequestDispatcher("listAllFlights.jsp").forward(req, resp);
		
	}

	
}
